-- CALC_ODD_FLOOR_BONUS

-- 奇怪的地板奖励
-- @param user      玩家对象
return function(user)
    local dungeonId = DungeonM.getDungeonId();
    local layer = DungeonM.currentLayer();
    local bonus = {};

    if DungeonAreaM.isEndlessArea(dungeonId) then
        local rand = DungeonM.getRandSeed("ODD_FLOOR");
        local rand1 = DungeonM.getRandSeed("ODD_FLOOR");
        local classId = FormulaM.invoke("FETCH_BY_RAND", { 1102, 1103 }, rand1);
        local arr;
        local arr1;

        if BuildingBonusM.getFieldStat("odd_floor_gem") < 10 then
            arr = { { ["bonus"] = { 2, "money", 300, }, ["ratio"] = 40, },
                    { ["bonus"] = { 1, classId, 3, }, ["ratio"] = 40, },
                    { ["bonus"] = { 2, "gem", 1, }, ["ratio"] = 20, },};
        else
            arr = { { ["bonus"] = { 2, "money", 300, }, ["ratio"] = 40, },
                    { ["bonus"] = { 1, classId, 3, }, ["ratio"] = 40, },};
        end

        arr1 = fetchElemBySeed(arr, rand);
        arr  = arr1["bonus"];

        -- 当前累计的地板奖励钻石
        -- 添加统计
        if arr[2] == "gem" then
           BuildingBonusM.addFieldStat("odd_floor_gem", arr[3]);
        end
        bonus = { arr, };
    else
        -- 小关卡
        if layer == 3 or layer == 12 then
            bonus = { 2, "money", 500 };
        else
            -- 第18F层奖励：5钻石（再次获得，则为【金币】×500）
            if NewbieDungeonM.isFirstNewbieBonus("odd_floor") then
                bonus = { 2, "gem", 5 };
                NewbieDungeonM.statNewbieFirstBonus("odd_floor");
            else
                bonus = { 2, "money", 500 };
            end
        end
    end

    return { ["bonus"] = bonus, };
end
